package com.okmin.base;

import android.content.Intent;
import android.os.Bundle;

/**
 * 这是一个提供fragment的activity
 */
public abstract class BaseFragmentActivity extends BaseActivity {

    //获取第一个fragment
    protected abstract BaseFragment getFirstFragment();

    //获取Intent
    protected void handleIntent(Intent intent) {

    }

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            if (null != getIntent()) {
                handleIntent(getIntent());
            }
            //避免重复添加Fragment
            if (null == getSupportFragmentManager().getFragments()) {
                BaseFragment firstFragment = getFirstFragment();
                if (null != firstFragment) {
                    addFragment(firstFragment);
                }
            }

        }
    @Override
    protected int getLayoutId() {
        return R.layout.item_recyclerview;
    }
}